# 解法一：
arr = [[0] * 10 for _ in range(10)]
total_product = 1  # 用于存储所有数的乘积

# 读入数据
for i in range(10):
    nums = input().split(" ")  # 输入每行的数字
    for j in range(10):
        arr[i][j] = int(nums[j])
        total_product *= arr[i][j]  # 更新总乘积

# 将总乘积转换为字符串，然后反转，这样末尾的零就变成了字符串的开头
total_product_str = str(total_product)[::-1]
count_0 = 0
for ch in total_product_str:
    if ch == '0':
        count_0 += 1
    else:
        break  # 一旦遇到非零数字，就停止计数

print(count_0)


def count_factors(n, factor):
    count = 0
    while n % factor == 0 and n > 0:
        count += 1
        n //= factor
    return count


arr = [[0] * 10 for i in range(10)]
count_5 = 0  # 用于统计因子5的数量

for i in range(10):
    nums = input().split(" ")
    for j in range(10):
        arr[i][j] = int(nums[j])
        # 对每个元素计算其中包含的因子5的个数，并累加
        count_5 += count_factors(arr[i][j], 5)

print(count_5)  # 打印因子5的总数量，即末尾零的数量
